<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计划任务信息列表</title>
    <script type="application/javascript" src="../js/jquery-1.11.1.min.js"></script>
    <script>
        $(function () {
            $.ajax({
                type: "POST",
                url: "http://127.0.0.1:8084/scheduled/list",
                dataType:"json",
                data: {},
                async: false,
                success: function (data) {
                    var list = data.model;
                    var appendHtml = "";
                    for(var i=0;i<list.length;i++){
                        var m  = list[i];
                        appendHtml = appendHtml + "<tr><td>"+m.id+"</td><td>"+m.cronKey+"</td>" +
                            "<td>"+m.cronExpression+"</td>" +
                            "<td>"+m.taskExplain+"</td>" +
                            "<td>"+m.status+"</td>" +
                            "<td>" +
                            "<button onclick='see("+m.id+")'>查看</button>&nbsp;&nbsp;&nbsp;" +
                            "<button onclick='update("+m.id+")'>修改</button>&nbsp;&nbsp;&nbsp;" +
                            "<button onclick='deletes("+m.id+")'>删除</button>" +
                            "</td>" +
                            "</tr>";
                    }
                    $("#tablelist").append(appendHtml);
                },
                error: function(data) {
                    console.log("出错："+data);
                }
            });





        });

    </script>
</head>
<body>



<div style="padding: 30px;">

    <button onclick="add()">添加</button>

    <table id="tablelist" border="1">
        <tr align="center">
            <td>id</td>
            <td>cronKey</td>
            <td>cronExpression</td>
            <td>taskExplain</td>
            <td>status</td>
            <td>操作</td>
        </tr>
    </table>
</div>


</body>


<script>

    function add() {
        location.href = "add.html";
    }

    function see(id) {
        $.ajax({
            type: "POST",
            url: "http://127.0.0.1:8084/scheduled/get",
            dataType:"json",
            data: {"id":id},
            async: false,
            success: function (data) {
                console.log(data);
                alert(data.cronKey + "--"+data.cronExpression);
            },
            error: function(data) {
                console.log("出错："+data);
            }
        });
    }

    function update(id) {
        var url = "update.html?id="+id;
        window.open(url,"_blank")
        //location.href = "update.html?id="+id; ;
    }

    function deletes(id) {
        if(confirm("确定删除吗?")){
            $.ajax({
                type: "POST",
                url: "http://127.0.0.1:8084/scheduled/delete/",
                dataType:"json",
                data: {"id":id},
                async: false,
                success: function (data) {
                    alert("已删除");
                    location.reload();
                },
                error: function(data) {
                    console.log("出错："+data);
                }
            });
        }
    }





</script>


</html>